package org.litespring.beans.factory;

import org.litespring.beans.BeansException;

/**
 * @author ChangLiang
 * @date 2020/7/21
 */
public class BeanCreationException extends BeansException {

    private String beanId;

    public BeanCreationException(String msg) {
        super(msg);
    }

    public BeanCreationException(String msg, Throwable cause) {
        super(msg, cause);
    }

    public BeanCreationException(String beanId, String msg) {
        super("Error creating bean with name '" + beanId + "': " + msg);
        this.beanId = beanId;
    }

    public BeanCreationException(String beanId, String msg, Throwable cause) {
        this(beanId, msg);
        // 记录下底层异常cause 防止捕获上层异常的时候 导致底层异常丢失
        initCause(cause);
    }

    public String getBeanId() {
        return this.beanId;
    }
}
